<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pncCalcPercent.php,v $
 * $Author: pcornelissen $
 * $Revision: 1.3 $
 * $Date: 2003/12/08 12:09:47 $
 *
 * Type: Function
 *
 * return the percentage for the given parameters
 *@param params['inPercent'] boolean if true, function returns something between 1 and 100, if false, range is 0 to 1 
 *@param params['basicValue'] int basic value ( this is treated as being 100%)
 *@param params['percentage'] int percentage (e.g. 13 for 13%)
 *@return int percentage value
 */
function smarty_function_pncCalcPercent($params, &$smarty)
{
    extract($params);
    if( ($basicValue == 0) | ($percentage == 0) )
    {
        return 0;
    }
    $result=$percentage/$basicValue;
    if($inPercent==true) $result*=100;
    return $result;
}
?>
